<#import "../macro/components.ftl" as components/>
<#include "../macro/layout_default.ftl"/>

<@head>
<link rel="stylesheet" href="/misc/app/css/branch_list.css"/>
</@head>

<@body>
<script src="/misc/jquery-fileupload-9.14.0/jquery.ui.widget.js"></script>
<script src="/misc/jquery-fileupload-9.14.0/jquery.fileupload.js"></script>
<script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=u6Klv6ue1txKAw3QTixzROMMxVid6NGe"></script>
<script src="/misc/app/js/branch_list.js"></script>
<script>var PicDomain = "${PicDomain!}"</script>
</@body>

<@layout_default>
<div class="box">
    <div class="box-header with-border">
        <span class="pull-right text-muted">共 ${branchList.resultTotal} 条记录</span>
        <input type="hidden" id="resultTotal_hidden" value="${branchList.resultTotal}" />
        <form class="form-inline" action="/branch">
            <div class="input-group">
                <div class="input-group-addon">关键词</div>
                <input type="text" class="form-control" style="width: 260px" name="keyword" value="${keyword!}" placeholder="输入兑奖网点"/>
            </div>
            <div class="input-group">
                <div class="input-group-addon">状态</div>
                <select class="form-control" name="state">
                    <option value="">全部</option>
                    <option value="1" ${(state?exists && state == 1)?string("selected","")}>正常</option>
                    <option value="2" ${(state?exists && state == 2)?string("selected","")}>停用</option>
                </select>
            </div>

            <button type="submit" class="btn btn-warning"><i class="fa fa-search"></i> 查询</button>
            <button type="button" class="btn btn-default" name="btn_new_branch" data-toggle="modal" data-target="#md_new_branch"><i class="fa fa-plus"></i> 新增兑奖网点</button>
            <#--<button type="button" class="btn btn-default"><i class="fa fa-random"></i> 同步至企业号通讯录</button>-->
        </form>
    </div>
    <!-- /.box-header -->
    <div class="box-body">
        <table class="table table-striped table-hover">
            <tr>
                <th>ID</th>
                <th>兑奖网点</th>
                <th>联系电话</th>
                <th>联系人</th>
                <th>详细地址</th>
                <th>状态</th>
                <th>备注</th>
                <th>操作</th>
            </tr>
            <#if (branchList.result?size > 0)>
                <#list branchList.result as item>
                    <tr>
                        <td>${item.id}</td>
                        <td>${item.name}</td>
                        <td>${item.linkPhone}</td>
                        <td>${item.linkMan}</td>
                        <td>${item.address}</td>
                        <td><#if item.state==1><span class="text-green">正常</span><#elseif item.state==2><span class="text-yellow">停用</span><#else><span class="text-danger">未知</span></#if></td>
                        <td>${item.remark!}</td>
                        <td>
                            <!-- <a class="btn btn-default btn-xs" name="btn_delete_salesman">兑奖记录</a> -->
                            <button type="button" class="btn btn-default btn-xs" data-toggle="modal" data-target="#md_edit_branch" data-branch-id="${item.id}">编辑</button>
                            <button type="button" class="btn btn-default btn-xs" name="btn_delete_branch" data-branch-id="${item.id}">删除</button>
                        </td>
                    </tr>
                </#list>
            <#else>
                <tr>
                    <td class="text-center text-muted" colspan="8"><i class="fa fa-info-circle"></i> 没有记录</td>
                </tr>
            </#if>
        </table>
        <table class="table table-striped table-hover">
        	<tr>
        		<td colspan="13" style="text-align:right;background-color:white;">
        			<a href="javascript:void(0);" name="btn_export"><i class="glyphicon glyphicon-save"></i> 数据导出</a>
        		</td>
        	</tr>
        </table>
    </div>
    <!-- /.box-body -->
    <div class="box-footer text-center">
        <@components.pagination "/branch?keyword=${keyword!}&state=${state!}&page=$page",branchList.page,branchList.pageTotal/>
    </div>
</div>


<!--=========== Modals =============-->
<!-- md_new_branch -->
<div class="modal" id="md_new_branch" tabindex="-1">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel"><i class="fa fa-plus"></i> 新增兑奖网点</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" name="form_new_branch">
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 兑奖网点</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" placeholder="兑奖网点" name="name"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 联系人</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" placeholder="联系人" name="linkMan"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 手机号</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" placeholder="手机号" name="linkPhone"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 部门</label>
                        <div class="col-sm-10">
                            <select class="form-control" name="departmentId">
                                <option value="">请选择部门</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 详细地址</label>
                        <div class="col-sm-10">
                            <div class="input-group">
                                <input type="text" class="form-control" placeholder="详细地址" name="address"/>
                                <span class="input-group-btn"><button type="button" class="btn btn-default" id="btn_new_branch_mapmarker"><i class="fa fa-map-marker"></i> 定位</button></span>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"></label>
                        <div class="col-sm-10">
                            <input type="hidden" name="geoPoint"/>
                            <div id="ctn_new_branch_bmap" class="bmap-container"></div>
                            <p class="help-block"><i class="fa fa-info-circle text-yellow"></i> 请在地图上标注兑奖网点的位置</p>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">备注</label>
                        <div class="col-sm-10">
                            <textarea class="form-control" name="remark" placeholder="备注 "></textarea>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 状态</label>
                        <div class="col-sm-10">
                            <select class="form-control" name="state">
                                <option value="1">正常</option>
                                <option value="2">停用</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">网点图片</label>
                        <div class="col-sm-10">
                            <p class="help-block"><i class="fa fa-info-circle text-yellow"></i> 点击预览图可删除图片，图片数量限制3张以内</p>
                            <span class="ctn-branch-pics" id="ctn_new_branch_pics"></span>
                            <input type="file" id="ipt_new_branch_upload_pic" class="hide" name="file"/>
                            <button type="button" class="btn-upload-branchimg" name="btn_new_branch_upload_pic"><i class="fa fa-plus"></i></button>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" name="btn_save_new_branch">保存</button>
            </div>
        </div>
    </div>
</div>

<!-- md_edit_branch -->
<div class="modal" id="md_edit_branch" tabindex="-1">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel"><i class="fa fa-pencil-square-o"></i> 编辑兑奖网点</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" name="form_edit_branch">
                    <input type="hidden" name="id"/>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 兑奖网点</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" placeholder="兑奖网点" name="name"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 联系人</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" placeholder="联系人" name="linkMan"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 手机号</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" disabled placeholder="手机号" name="linkPhone"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 部门</label>
                        <div class="col-sm-10">
                            <select class="form-control" name="departmentId">
                                <option value="">请选择部门</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 详细地址</label>
                        <div class="col-sm-10">
                            <div class="input-group">
                                <input type="text" class="form-control" placeholder="详细地址" name="address"/>
                                <span class="input-group-btn"><button type="button" class="btn btn-default" id="btn_edit_branch_mapmarker"><i class="fa fa-map-marker"></i> 定位</button></span>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"></label>
                        <div class="col-sm-10">
                            <input type="hidden" name="geoPoint"/>
                            <div id="ctn_edit_branch_bmap" class="bmap-container"></div>
                            <p class="help-block"><i class="fa fa-info-circle text-yellow"></i> 请在地图上标注兑奖网点的位置</p>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">备注</label>
                        <div class="col-sm-10">
                            <textarea class="form-control" name="remark" placeholder="备注 "></textarea>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 状态</label>
                        <div class="col-sm-10">
                            <select class="form-control" name="state">
                                <option value="1">正常</option>
                                <option value="2">停用</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">网点图片</label>
                        <div class="col-sm-10">
                            <p class="help-block"><i class="fa fa-info-circle text-yellow"></i> 点击预览图可删除图片，图片数量限制3张以内</p>
                            <span class="ctn-branch-pics" id="ctn_edit_branch_pics"></span>
                            <input type="file" id="ipt_edit_branch_upload_pic" class="hide" name="file"/>
                            <button type="button" class="btn-upload-branchimg" name="btn_edit_branch_upload_pic"><i class="fa fa-plus"></i></button>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" name="btn_save_edit_branch">保存</button>
            </div>
        </div>
    </div>
</div>

</@layout_default>